import { createRouter, createWebHashHistory } from "vue-router";

// 定义router
const router = createRouter({
	history: createWebHashHistory(), // hash模式
	// 路由配置
	routes: [
		{
			path: "/",
			name: "home",
			// 路由懒加载：实现路由组件的按需加载
			component: () => import("../view/DiscoverMusic"),
			children: [
				{
					path: "",
					component: () => import("../view/DiscoverMusic/Recommended"),
				},
				{
					path: "rankinglist",
					component: () => import("../view/DiscoverMusic/RankingList"),
				},
				{
				path: "singer",
					component: () => import("../view/DiscoverMusic/Singer")
				},
				{
					path: "songlist",
					component: () => import("../view/DiscoverMusic/SongList")
				},
				{
					path: "/newdisc",
					component: () => import("../view/DiscoverMusic/NewDisc"),
				},
				{
					path:'anchorstation',
					component:()=>import('../view/DiscoverMusic/AnchorStation')
				}
			],
		},
		{
			path: "/music",
			name: "music",
			// 路由懒加载：实现路由组件的按需加载
			component: () => import("../view/MusicView"),
		},
	],
	// 滚动行为
	// 当路由跳转时触发，返回值决定滚动条的位置
	scrollBehavior() {
		// 始终滚动到顶部
		return { top: 0 };
	},
});

// 必须登录才能访问的路由表
// const permissionRoutes = [];

// 配置路由全局导航守卫
// router.beforeEach((to, from, next) => {
// 	// 判断要去的路由地址是否在权限路由表中
// 	if (permissionRoutes.includes(to.path) && !store.state.user.token) {
// 		next("/login");
// 		return;
// 	}

// 	next();
// });

export default router;
